const App = {
    mixins:[Save],//配置文件，路径/utils/mixins.js
    data() {
        return {
            category:[],
            city:[],
            cityValue:[],
            city1:[],
            cityValue1:[],
            personal:[],
            Land_Usage:[],
        };
    },
    mounted() {
        this.getCity();
        this.getCategory();
    },
    watch:{
        'dataForm.Land_SerialNumber'(val){
            this.cityValue = [this.dataForm.Province_Number,this.dataForm.Ctiy_Number, this.dataForm.County_Number];
            this.cityValue1 = [this.dataForm.Town_Number , this.dataForm.Village_Number];
            if (this.dataForm.County_Number) {
                $.ajax({
                    headers: requestHeaders(),
                    url: `${mh}/clientOperation/getDistrictTree`,
                    type: "GET",
                    data: {
                        DistrictCode: this.dataForm.County_Number
                    },
                    success: (data) => {
                       this.city1 = data[0].children;
                    },
                    complete: (XMLHttpRequest) => {
                        requestPretreatment(XMLHttpRequest);
                    },
                    dataType: "json",
                });
            }
            
        },

    },
    methods: {
        getCategory(){
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: "POST",
                data: {
                    Data: 'land_type',
                    Condition: "Row_Status='0'",
                },
                success: (data) => {
                    this.category = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: "POST",
                data: {
                    Data: 'land_usage',
                    Condition: "Row_Status='0'",
                },
                success: (data) => {
                    this.Land_Usage = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
            
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: "POST",
                data: {
                    Data: 'personal_information',
                    Condition: "Row_Status='0'",
                },
                success: (data) => {
                    this.personal = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
        },
        getCity(){
            $.ajax({
                url: `${absolutepath()}api/Districtjl.json`,
                method: "get",
                success: (data) => {
                    data.forEach(item=>{
                        item.children.forEach(ite=>{
                            ite.children.forEach(it=>{
                                it.children = undefined
                            })
                        })
                    })
                    this.city = data;
                }
            });
        },
        changeCity(val){
            if (val.length > 0) {
                this.dataForm.Province_Number = val[0];
                this.dataForm.Ctiy_Number = val[1];
                this.dataForm.County_Number = val[2];
                // this.dataForm.Town_Number = val[3];
                if (this.dataForm.County_Number) {
                    $.ajax({
                        headers: requestHeaders(),
                        url: `${mh}/clientOperation/getDistrictTree`,
                        type: "GET",
                        data: {
                            DistrictCode: this.dataForm.County_Number
                        },
                        success: (data) => {
                           this.city1 = data[0].children;
                        },
                        complete: (XMLHttpRequest) => {
                            requestPretreatment(XMLHttpRequest);
                        },
                        dataType: "json",
                    });
                }
               
            } else {
                this.dataForm.Province_Number = '';
                this.dataForm.Ctiy_Number = '';
                this.dataForm.County_Number = '';
                // this.dataForm.Town_Number = '';
            }
        },
        changeCity1(val){
            if (val.length > 0) {
                this.dataForm.Town_Number = val[0];
                this.dataForm.Village_Number = val[1];
            } else {
                this.dataForm.Town_Number = '';
                this.dataForm.Village_Number = '';
            }
        }
    },
};
const { createApp, ref } = Vue;
const app = createApp(App);
app.use(ElementPlus, { locale: zhCn });
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.mount("#app");
